
/**
 * @brief 文件夹类
 */
#include <filesystem>
#include <iostream>
#include "ce_file_folder.h"
#include "ce_file.h"



CE_FileFolder::CE_FileFolder(CE_FileFolder *parent, std::string relative_path, std::string absolute_path)
{
    this->parent = parent;
    // 相对路径
    this->relative_path = relative_path;
    // 绝对路径
    this->absolute_path = absolute_path;
    // 名称
    this->name = std::filesystem::path(absolute_path).filename().string();
    std::cout << "绝对路径: " << absolute_path << std::endl;
    std::cout << "相对路径: " << relative_path << std::endl;
    std::cout << "名称: " << name << std::endl;

    // 文件列表
    this->_load();
}
/**
 * @brief 加载文件夹
 */
void CE_FileFolder::_load()
{
    // 先收集当前目录条目
    // try
    // {
    //     for (const auto &entry : std::filesystem::directory_iterator(this->absolute_path))
    //     {
    //         std::filesystem::path absolute_path = entry.path();
    //         std::filesystem::path relative_path = std::filesystem::relative(absolute_path, Global::root_path);
    //         if (std::filesystem::is_directory(absolute_path))
    //         {
    //             // 文件夹
    //             CE_FileFolder *folder = new CE_FileFolder(this, relative_path, absolute_path);
    //             this->folders.push_back(folder);
    //         }
    //         else
    //         {
    //             // 文件
    //             CE_File *folder = new CE_File(this, relative_path, absolute_path);
    //             this->files.push_back(folder);
    //         }
    //     }
    // }
    // catch (const std::filesystem::filesystem_error &e)
    // {
    //     std::cerr << "bbb: " << e.what() << std::endl;
    //     return;
    // }
}

CE_FileFolder::~CE_FileFolder()
{
}
